package com.wei.frame.ui.activity;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.wei.frame.bean.NewsBean;
import com.wei.frame.contract.SplashContract;
import com.wei.frame.databinding.ActivitySplashBinding;
import com.wei.frame.di.component.AppComponent;
import com.wei.frame.presenter.SplashPresenter;
import com.wei.frame.ui.adapter.BaseRecyclerViewAdapter;

import java.util.List;

import javax.inject.Inject;
import javax.inject.Named;

/**
 * 作者:赵若位
 * 时间:2020/8/20 11:24
 * 功能:
 */
public class SplashActivity extends BaseActivity<ActivitySplashBinding, SplashPresenter> implements SplashContract.View {

    @Inject
    BaseRecyclerViewAdapter<NewsBean> mAdapter;

    @Inject
    @Named("Vertical")
    LinearLayoutManager mManager;

    @Override
    public boolean isInject(AppComponent component) {
        return true;
    }

    @Override
    public Class<ActivitySplashBinding> getBindingClass() {
        return ActivitySplashBinding.class;
    }

    @Override
    public void initView() {
        mBinding.rv.setLayoutManager(mManager);
        mAdapter.bindRecyclerView(mBinding.rv);
    }

    @Override
    public void initData() {
        mPresenter.getNewsData();
    }

    @Override
    public void onShowNewsData(@Nullable List<NewsBean> list) {
        if (null != mAdapter) {
            mAdapter.setNewData(list);
        }
    }
}
